import {createRouter, createWebHistory, createWebHashHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'
import AdminView from '../views/AdminView.vue'
import SpaceView from '../views/SpaceView.vue'
import SettingView from '../views/SettingView.vue'
import EventIndex from '../views/event/EventIndex.vue'
import E1 from '../views/event/E1.vue'
import E1Work from '../views/event/E1Work.vue'
import BBSView from '../views/BBSView.vue'
import NoticeView from '../views/NoticeView.vue'
import BBSWorld from '../components/bbs/world/world.vue'
import BBSWorldIndex from '../components/bbs/world/worldIndex.vue'
import BBSWorldPost from '../components/bbs/world/worldPost.vue'
import BBSForums from '../components/bbs/forums/forums.vue'
import BBSForumsIndex from '../components/bbs/forums/forumsIndex.vue'
import BBSForumsSubarea from '../components/bbs/forums/forumsSubarea.vue'
import BBSForumsTopic from '../components/bbs/forums/forumsTopic.vue'
import BBSPostTransfer from '../components/bbs/postTransfer.vue'
import BBSForumsPost from '../components/bbs/forums/forumsPost.vue'
import BBSForumsPublish from '../components/bbs/forums/forumsPublish.vue'
import BBSSearchResult from '../components/bbs/search/searchResult.vue'
import {Server} from '@/stores/ajax'

const router = createRouter({
    history: createWebHashHistory(),
    // history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            component: HomeView
        },
        {
            path: '/admin',
            component: AdminView
        },
        {
            path: '/bbs',
            component: BBSView,
            redirect: '/bbs/world',
            children: [
                {
                    path: 'world',
                    component: BBSWorld,
                    children: [
                        {
                            path: '',
                            component: BBSWorldIndex,
                        }, {
                            path: 'post/:postid/:to?',//to是滚动到哪
                            component: BBSWorldPost,
                        }
                    ],
                },
                {
                    path: 'forums',
                    component: BBSForums,
                    children: [
                        {
                            path: '',
                            component: BBSForumsIndex,
                        }, {
                            path: 'subarea/:subareaid',
                            component: BBSForumsSubarea,
                        }, {
                            path: 'topic/:tid/',
                            redirect: to => {
                                return `/bbs/forums/topic/${to.params.tid}/page/1`
                            }
                        }, {
                            path: 'topic/:tid/page/:page',
                            component: BBSForumsTopic,
                        }, {
                            path: 'topic/:tid/to/:to',
                            component: BBSForumsTopic,
                        }, {
                            path: 'post/:pid/:to?',
                            component: BBSForumsPost,
                        }, {
                            path: 'publish/:subareaid',
                            component: BBSForumsPublish
                        }
                    ],
                }, {
                    path: 'postTransfer/:pid/',
                    component: BBSPostTransfer,

                }, {
                    path: 'search/:for/:str',
                    alias: 'search',
                    component: BBSSearchResult,
                }
            ]
        },
        {
            path: '/event',
            component: EventIndex,
        },
        {
            path: '/event/e1/:sid',
            component: E1,
        },
        {
            path: '/event/e1work/:tid',
            component: E1Work,
        },
        {
            name: 'space',
            path: '/space/:userid',
            component: SpaceView
        },
        {
            name: 'mysettings',
            path: '/mysettings',
            component: SettingView
        },
        {
            name: 'notice',
            path: '/notice',
            component: NoticeView
        }

    ]
})

export default router
